package io.shallwe._admin.line;

import com.jfinal.aop.Aop;
import com.jfinal.aop.Inject;

import io.shallwe.common.controller.BaseController;
import io.shallwe.common.model.LineInfo;

/**
 * 产线挂框信息
 * @author 王小伟
 * @date 2019-06-10 21:17:33
 */
public class LineRackController extends BaseController {


	LineInfoService service = Aop.get(LineInfoService.class);

	public void index() {
		checkUrlPara(0);
		render("index.html");
	}

	/*
	 * 分页列表数据
	 */
	public void list() {
		Integer offset = getParaToInt("offset", 1);
		Integer pageSize = getParaToInt("pageSize", 100);
		String traceCode=get("traceCode");
		String rackNo=get("rackNo");
		renderJson(service.paginate(offset, pageSize,traceCode,rackNo));
	}

	/**
	 * 新增页面
	 */
	public void add() {
		render("add_edit.html");
	}

	/**
	 * 新增保存
	 */
	public void save() {
		LineInfo lineInfo = getBean(LineInfo.class, "lineRack");
		renderJson(service.save(lineInfo));
	}

	/**
	 * 编辑页面
	 */
	public void edit() {
		Integer id=getParaToInt("id",-1);
		LineInfo lineInfo=service.findById(id);
		set("lineInfo", lineInfo);
		render("add_edit.html");
	}

	/**
	 * 编辑更新
	 */
	public void update() {
		LineInfo lineInfo = getBean(LineInfo.class, "lineInfo");
		renderJson(service.update(lineInfo));
	}

	/**
	 * 删除
	 */
	public void delete() {
		String id = get("id");
		renderJson(service.delete(id));
	}

	/**
	 * 挂框前进
	 */
	public void rackForward() {
		Integer id=getParaToInt("id",-1);
		renderJson(service.rackForward(id));
	}

	/**
	 * 挂框后退
	 */
	public void rackBackward() {
		Integer id=getParaToInt("id",-1);
		renderJson(service.rackBackward(id));
	}

	/**
	 * 整线前进
	 */
	public void lineForward() {
		renderJson(service.lineForward());
	}

	/**
	 * 整线后退
	 */
	public void lineBackward() {
		renderJson(service.lineBackward());
	}
	
	
	public void print() {
		render("printPage.html");
	}
}
